<!DOCTYPE html>
<html lang="zh-Hant">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$page_title} - {$site_name}</title>
    <meta name="description" content="{$page_description}">
    {block name="canonical"}{/block}
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="/static/css/style.css?v=11">
    {block name="head"}{/block}
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#8E44AD',
                        secondary: '#3498DB',
                        accent: '#E74C3C',
                        success: '#2ECC71',
                        warning: '#F39C12',
                        info: '#1ABC9C',
                        light: '#F5F7FA',
                        dark: '#34495E'
                    }
                }
            }
        }
    </script>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar shadow-md">
        <div class="container mx-auto px-4 py-3">
            <div class="flex justify-between items-center">
                <!-- Logo -->
                <a href="/" class="text-white text-2xl font-bold">{$site_name}</a>
                
                <!-- 搜索框 -->
                <div class="hidden md:block w-1/3 search-box">
                    <form action="/search" method="get">
                        <div class="relative">
                            <input type="text" name="keyword" placeholder="搜索桌布..." class="w-full px-4 py-2 rounded-full focus:outline-none">
                            <button type="submit" class="search-btn absolute right-0 top-0 h-full px-4 rounded-r-full text-white">
                                <i class="fas fa-search"></i>
                            </button>
                        </div>
                    </form>
                </div>
                
                <!-- 导航链接 -->
                <div class="hidden md:flex items-center space-x-6">
                    <a href="/" class="text-white hover:text-accent">首頁</a>
                    <a href="/category/<?php echo rawurlencode('電腦桌布')?>/" class="text-white hover:text-primary">
                        <i class="fas fa-desktop mr-1"></i>電腦桌布
                    </a>
                    <a href="/category/<?php echo rawurlencode('手機桌布')?>/" class="text-white hover:text-accent">
                        <i class="fas fa-mobile-alt mr-1"></i>手機桌布
                    </a>
                    <div class="relative group">
                        <a href="#" class="text-white hover:text-accent">分類 <i class="fas fa-chevron-down text-xs ml-1"></i></a>
                        <div class="absolute top-full left-0 mt-2 w-64 bg-white rounded-md shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-300 z-50">
                            <div class="flex">
                                <a href="/category/<?php echo rawurlencode('電腦桌布')?>/" class="block w-1/2 px-4 py-3 text-sm font-medium text-primary bg-gray-100 hover:bg-gray-200 border-b border-r">
                                    <i class="fas fa-desktop mr-2"></i>電腦桌布
                                </a>
                                <a href="/category/<?php echo rawurlencode('手機桌布')?>/" class="block w-1/2 px-4 py-3 text-sm font-medium text-accent bg-gray-100 hover:bg-gray-200 border-b">
                                    <i class="fas fa-mobile-alt mr-2"></i>手機桌布
                                </a>
                            </div>
                            <div class="grid grid-cols-2">
                                <div class="border-r">
                                    {volist name="categories" id="category"}
                                    <a href="/category/<?php echo rawurlencode('電腦桌布')?>/{$category.name|rawurlencode}" class="block px-4 py-2 text-sm text-dark hover:bg-light hover:text-primary border-b">
                                        {$category.name}
                                    </a>
                                    {/volist}
                                </div>
                                <div>
                                    {volist name="categories" id="category"}
                                    <a href="/category/<?php echo rawurlencode('手機桌布')?>/{$category.name|rawurlencode}" class="block px-4 py-2 text-sm text-dark hover:bg-light hover:text-accent border-b">
                                        {$category.name}
                                    </a>
                                    {/volist}
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 用户头像图标 -->
                    <div class="relative">
                        <button id="userAvatarBtn" class="text-white hover:text-accent transition-colors duration-300">
                            {if condition="!empty($user_info['nickname'])"}
                            <!-- 已登录用户 -->
                            <div class="flex items-center space-x-2">
                                <div class="w-8 h-8 rounded-full overflow-hidden border-2 border-white border-opacity-30 hover:border-opacity-50 transition-all duration-300">
                                    {if condition="!empty($user_info['avatar'])"}
                                    <img src="{$user_info.avatar}" alt="用户头像" class="w-full h-full object-cover">
                                    {else/}
                                    <div class="w-full h-full bg-gradient-to-br from-primary to-secondary flex items-center justify-center">
                                        <i class="fas fa-user text-white text-sm"></i>
                                    </div>
                                    {/if}
                                </div>
                                <span class="text-sm font-medium hidden lg:block">{$user_info.nickname}</span>
                            </div>
                            {else/}
                            <!-- 未登录用户 -->
                            <div class="w-8 h-8 rounded-full bg-white bg-opacity-20 flex items-center justify-center hover:bg-opacity-30 transition-all duration-300">
                                <i class="fas fa-user text-lg"></i>
                            </div>
                            {/if}
                        </button>
                    </div>
                </div>
                
                <!-- 移动端菜单按钮 -->
                <div class="md:hidden flex items-center space-x-3">
                    <!-- 移动端用户头像 -->
                    <button id="mobileUserAvatarBtn" class="text-white hover:text-accent">
                        {if condition="!empty($user_info['nickname'])"}
                        <!-- 已登录用户 -->
                        <div class="w-8 h-8 rounded-full overflow-hidden border-2 border-white border-opacity-30 hover:border-opacity-50 transition-all duration-300">
                            {if condition="!empty($user_info['avatar'])"}
                            <img src="{$user_info.avatar}" alt="用户头像" class="w-full h-full object-cover">
                            {else/}
                            <div class="w-full h-full bg-gradient-to-br from-primary to-secondary flex items-center justify-center">
                                <i class="fas fa-user text-white text-sm"></i>
                            </div>
                            {/if}
                        </div>
                        {else/}
                        <!-- 未登录用户 -->
                        <div class="w-8 h-8 rounded-full bg-white bg-opacity-20 flex items-center justify-center hover:bg-opacity-30 transition-all duration-300">
                            <i class="fas fa-user"></i>
                        </div>
                        {/if}
                    </button>
                    <button id="menuBtn" class="text-white text-xl">
                        <i class="fas fa-bars"></i>
                    </button>
                </div>
            </div>
            
            <!-- 移动端菜单 -->
            <div id="mobileMenu" class="hidden md:hidden mt-4">
                <div class="mb-4">
                    <form action="{:url('index/search')}" method="get">
                        <div class="relative">
                            <input type="text" name="keyword" placeholder="搜索桌布..." class="w-full px-4 py-2 rounded-full focus:outline-none">
                            <button type="submit" class="search-btn absolute right-0 top-0 h-full px-4 rounded-r-full text-white">
                                <i class="fas fa-search"></i>
                            </button>
                        </div>
                    </form>
                </div>
                <div class="flex flex-col space-y-2">
                    <a href="{:url('index/index')}" class="text-white hover:text-accent py-2">首頁</a>
                    <a href="/category/<?php echo rawurlencode('電腦桌布')?>/" class="text-white hover:text-primary py-2">
                        <i class="fas fa-desktop mr-1"></i>電腦桌布
                    </a>
                    <a href="/category/<?php echo rawurlencode('手機桌布')?>/" class="text-white hover:text-accent py-2">
                        <i class="fas fa-mobile-alt mr-1"></i>手機桌布
                    </a>
                    <div class="py-2">
                        <a href="#" id="mobileCategory" class="text-white hover:text-accent">分類 <i class="fas fa-chevron-down text-xs ml-1"></i></a>
                        <div id="mobileCategoryMenu" class="hidden pl-4 mt-2 space-y-2">
                            <div class="flex flex-wrap gap-2">
                                {volist name="categories" id="category"}
                                <a href="/category/<?php echo rawurlencode('手機桌布')?>/{$category.name|rawurlencode}" class="inline-block text-white hover:text-accent px-3 py-1 text-sm bg-white bg-opacity-10 rounded-full hover:bg-opacity-20 transition-all duration-300">
                                    {$category.name}
                                </a>
                                {/volist}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </nav>
    
    <!-- 用户信息侧边栏容器 -->
    <div id="userSidebarContainer"></div>
    
    <!-- 主要内容 -->
    <main class="container mx-auto px-4 py-8">
        {block name="content"}{/block}
    </main>
    
    <!-- 返回顶部按钮 -->
    <div id="backToTop" class="fixed bottom-8 right-8 bg-primary text-white w-12 h-12 rounded-full flex items-center justify-center cursor-pointer shadow-md z-50 hover:bg-purple-700">
        <i class="fas fa-arrow-up"></i>
    </div>
    
    <!-- 页脚 -->
    <footer class="footer mt-12 py-8">
        <div class="container mx-auto px-4">
            <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
                <div>
                    <h3 class="text-xl font-bold mb-4">關於我們</h3>
                    <p class="text-gray-300">{$site_description}</p>
                    <a href="/about" class="text-accent hover:underline mt-3 inline-block">了解更多 <i class="fas fa-chevron-right ml-1 text-xs"></i></a>
                </div>
                {if condition="isset($links_list) && !empty($links_list)"}
                <div>
                    <h3 class="text-xl font-bold mb-4">友情鏈接</h3>
                    <ul class="space-y-2 text-gray-300">
                        {volist name="links_list" id="link"}
                        <li><a href="{$link.url}" target="_blank" title="{$link.site_name}">{$link.site_name}</a></li>
                        {/volist}
                    </ul>
                </div>
                {/if}
                <div>
                    <h3 class="text-xl font-bold mb-4">聯繫我們</h3>
                    <p class="text-gray-300">有任何問題或建議？請聯繫我們的客服團隊。</p>
                    <div class="flex space-x-4 mt-4">
                        <a href="#" class="text-white hover:text-accent"><i class="fab fa-facebook-f"></i></a>
                        <a href="#" class="text-white hover:text-accent"><i class="fab fa-twitter"></i></a>
                        <a href="#" class="text-white hover:text-accent"><i class="fab fa-instagram"></i></a>
                    </div>
                </div>
            </div>
            <div class="mt-8 pt-8 border-t border-gray-700 text-center text-gray-300">
                <div class="text-sm">
                    <a href="/terms" class="hover:text-accent mx-2">使用條款</a>
                    <span class="text-gray-600">|</span>
                    <a href="/privacy" class="hover:text-accent mx-2">隱私政策</a>
                </div>
            </div>
        </div>
    </footer>
    
    <!-- JavaScript -->
    <script>
        let att_domain = '{$att_domain_protocol}{$att_domain}';
        let google_login_url = "{$google_login_url}";
        let userType = "{$user_info.user_type}";
        let userName = "{$user_info.nickname}";
        let userAvatar = "{$user_info.avatar}";
    </script>
    <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>  
    <script src="/static/js/common.js?v=11"></script>
    {block name="script"}{/block}
    <!-- Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-5JV1G8YGKV"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-5JV1G8YGKV');
    </script>
    
    <!-- Microsoft Clarity -->
    <script>
        (function(c,l,a,r,i,t,y){
            c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
            t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i+"?ref=bwt";
            y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
        })(window, document, "clarity", "script", "rlfaclowcr");
    </script>
</body>
</html> 